package com.sgb.kjwl.view.ui.adapter.machine;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.sgb.kjwl.BR;
import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.self.LeaseFactoryEntity;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;
import com.swgk.core.util.DateUtils;

import java.util.List;

/**
 * 工厂列表itme
 */
public class LeaseFactoryAdapter extends BaseRecycleAdapter<LeaseFactoryEntity> {

    private TextView tv_time;
    private TextView tvIsSelf;

    public LeaseFactoryAdapter(Context context, List<LeaseFactoryEntity> datas) {
        super(context, R.layout.item_lease_factory, datas);
    }

    @Override
    public void convert(ItemViewHolder holder, final LeaseFactoryEntity entity) {
        holder.setBinding(BR.viewModel, entity);
        tv_time = holder.itemView.findViewById(R.id.tv_time);
        tvIsSelf = holder.getItem().findViewById(R.id.tv_isSelf);
        tvIsSelf.setVisibility("1".equals(entity.getIsSelf()) ? View.VISIBLE : View.INVISIBLE);
        try {
            tv_time.setText(DateUtils.stampToDay(entity.getUpdateTime()));
        } catch (Exception e) {

        }
    }

}
